package creditcard.mvc;

import framework.Utils;
import framework.mvc.ACustomButton;
import framework.mvc.AFincoView;
import framework.mvc.FincoContext;

import java.util.Map;

public class AddCCardAccountButton extends ACustomButton {

    public AddCCardAccountButton(AFincoView view) {
        super(view, "Add Credit-Card Account");
    }

    @Override
    public void fireClick() {
        AddCCardAccountDialog dialog = new AddCCardAccountDialog(view);
        dialog.setBounds(450, 20, 300, 380);
        dialog.setVisible(true);

        if (!dialog.isCreated())
            return;

        Map<String, String> cusMap = dialog.getCustomerMap();

        view.getViewModel().addRow(Utils.map2row(HeaderUtils.getCCHeader(), cusMap));
        FincoContext.getFinco().addRow(cusMap);
        view.unselectRow();
    }
}
